package cn.imnaer.service.rest.feedback.impl;

import cn.imnaer.common.factory.JacksonUtil;
import cn.imnaer.service.persistence.model.Feedback;
import cn.imnaer.service.persistence.model.Version;
import cn.imnaer.service.rest.feedback.FeedbackComponentRestApi;
import cn.imnaer.service.rest.view.model.SimpleResponse;
import cn.imnaer.service.rpc.feedback.impl.FeedbackComponentRpcApiImpl;

import javax.jws.WebService;
import java.util.HashMap;

@WebService
public class FeedbackComponentRestApiImpl implements FeedbackComponentRestApi {

    @Override
    public String feedback(String feedbackJson) {
        Feedback feedback = (Feedback) JacksonUtil.jsonToBean(feedbackJson, Feedback.class);
        new FeedbackComponentRpcApiImpl().feedback(feedback);
        return new SimpleResponse().success();
    }

    @Override
    public String getLastVersion() {
        HashMap<String, String> versionMap = new HashMap<String, String>();
        Version version = new FeedbackComponentRpcApiImpl().getVersion();
        versionMap.put("version", version.getVersion());
        return new SimpleResponse().success(versionMap);
    }
    @Override
    public String getSmallVersion() {
        HashMap<String, String> versionMap = new HashMap<String, String>();
        Version version = new FeedbackComponentRpcApiImpl().getSmallVersion();
        versionMap.put("version", version.getVersion());
        return new SimpleResponse().success(versionMap);
    }


}
